//
//  AppDelegate.m
//  创建控制器的三种方式
//
//  Created by 伍银荣 on 2021/6/23.
//  Copyright © 2021 com.example. All rights reserved.
//

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    _window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    //又拖了一个viewController,这是需要根据控制器的id来确定这个控制器
    UIStoryboard *board = [UIStoryboard storyboardWithName:@"WYRViewController" bundle:nil];
    UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"redVC"];
    
    
    _window.rootViewController = vc;
    
    [_window makeKeyAndVisible];
    
    
    
    return YES;
}

#pragma mark - 纯代码创建控制器的方式
- (void)code {
    FirstViewController *firstVC = [[FirstViewController alloc]init];
    _window.rootViewController = firstVC;
}

#pragma mark - xib创建控制器的方式
- (void)xib {
    //1.xib文件名称和控制器名一致
    SecondViewController *secondVC = [[SecondViewController alloc]init];
    
    //2.xib文件名和控制器名没有规律
    SecondViewController *secondVC2 = [[SecondViewController alloc]initWithNibName:@"CMMD" bundle:nil];
    
    //3.xib文件名和控制器名相似
    SecondViewController *secondVC3 = [[SecondViewController alloc]init];
}

#pragma mark - storyboard创建控制器的方式
- (void)storyboard {
    //首先加载storyboard文件
//    UIStoryboard *board = [UIStoryboard storyboardWithName:@"WYRViewController" bundle:nil];
//    //从storyboard中实例化控制器
//    UIViewController *vc = [board instantiateInitialViewController];
    
    //又拖了一个viewController,这是需要根据控制器的id来确定这个控制器
    UIStoryboard *board = [UIStoryboard storyboardWithName:@"WYRViewController" bundle:nil];
    UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"redVC"];
    
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
